/* Copyright (c) 2008, RDFfs - Andrea Marchesini <baku@morlardf.net>
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

#include <glib.h>
#include <redland.h>

#define FUSE_USE_VERSION 26
#include <fuse.h>

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>

#define LICENSE			"BSD"
#define AUTHOR			"Andrea Marchesini"

#define RDF_VERSION_STRING	PACKAGE " " VERSION " - " LICENSE "\n"

#define RDF_SUBJECT_DIR		"subjects"
#define RDF_BNODE_DIR		"bnodes"
#define RDF_TRIPLES_DIR		"triples"

#define RDF_VERSION_FILE	"version"

#define RDF_INPUT_DIR		"input"
#define RDF_INPUT_SOURCE_FILE	"source"
#define RDF_INPUT_ERROR_FILE	"error"

#define RDF_SUBJECT_FILE	"subject"
#define RDF_PREDICATE_FILE	"predicate"
#define RDF_LANG_FILE		"language"
#define RDF_DATATYPE_FILE	"datatype"
#define RDF_TYPE_FILE		"type"
#define RDF_OBJECT_FILE		"object"

struct
{
  GList *subjects;
  guint subjects_size;

  GList *bnodes;
  guint bnodes_size;

  gchar *input;
  gsize input_size;

  gchar *filename;

  gchar *error;
  gsize error_size;

} rdf_input;

enum rdf_object_t
{
  RDF_OBJECT_BNODE,
  RDF_OBJECT_LITERAL,
  RDF_OBJECT_RESOURCE
};

struct rdf_t
{
  gchar *subject;
  gsize subject_size;

  gboolean subject_bnode;

  GList *triples;
};

struct rdf_triple_t
{
  gchar *predicate;
  gsize predicate_size;

  gchar *object;
  gsize object_size;
  enum rdf_object_t object_type;

  gchar *lang;
  gsize lang_size;

  gchar *datatype;
  gsize datatype_size;
};

struct fuse_operations rdf_oper;

/* Prototypes **************************************************************/
void		rdf_free 		(struct rdf_t *		rdf);

void		rdf_triple_free		(struct rdf_triple_t *	triple);

void		rdf_destroy_data	(void);

void		rdf_destroy		(void *			dummy);

gboolean	rdf_parse		(gchar *		buffer,
					 gchar *		file,
					 gchar **		error,
					 gsize *		error_size);

/* EOF */
